import Mock from 'mockjs';

import { prefixAPI } from '@/config/global';
import { SUCCESS_CODE } from '@/constants';

const listItem = {
  id: '@id',
  sn: /^[A-Za-z0-9]{12}$/,
  dev_name: '@cword(5,10)',
};

export default [
  {
    url: `${prefixAPI}/mock/list`,
    method: 'get',
    timeout: 1000,
    response: () => ({
      ...Mock.mock({
        code: SUCCESS_CODE,
        msg: 'string',
        data: {
          total: 30,
          'list|30': [listItem],
        },
      }),
    }),
  },
  {
    url: `${prefixAPI}/mock/create`,
    method: 'post',
    timeout: 2000,
    response: () => ({
      ...Mock.mock({
        code: SUCCESS_CODE,
        msg: 'string',
        data: {},
      }),
    }),
  },
  {
    url: `${prefixAPI}/mock/update`,
    method: 'post',
    timeout: 2000,
    response: () => ({
      ...Mock.mock({
        code: SUCCESS_CODE,
        msg: 'string',
        data: {},
      }),
    }),
  },
  {
    url: `${prefixAPI}/mock/del`,
    method: 'post',
    timeout: 2000,
    response: () => ({
      ...Mock.mock({
        code: SUCCESS_CODE,
        msg: 'string',
        data: {},
      }),
    }),
  },
  {
    url: `${prefixAPI}/mock/info`,
    method: 'get',
    timeout: 1000,
    response: () => ({
      ...Mock.mock({
        code: SUCCESS_CODE,
        msg: 'string',
        data: { ...listItem },
      }),
    }),
  },
];
